local fulong = fk.CreateSkill {
  name = "lingling__fulong",
}

Fk:loadTranslationTable{
  ["lingling__fulong"] = "抚龙",
  [":lingling__fulong"] = "出牌阶段限一次，你可以令一名其他角色视为对你或你指定的另一名角色使用【决斗】，"..
  "若其手牌中有【杀】，其响应此【决斗】不能“取消”。",

  ["#lingling__fulong"] = "抚龙：令一名角色视为使用【决斗】",
  ["#lingling__fulong-choose"] = "抚龙：选择一名角色，%dest 视为对其或你使用【决斗】",
  ["#lingling__fulong-use"] = "抚龙：请视为使用【决斗】",
}

fulong:addEffect("active", {
  anim_type = "offensive",
  prompt = "#lingling__fulong",
  card_num = 0,
  target_num = 1,
  can_use = function(self, player)
    return player:usedSkillTimes(fulong.name, Player.HistoryPhase) == 0
  end,
  card_filter = Util.FalseFunc,
  target_filter = function(self, player, to_select, selected)
    return #selected == 0 and to_select ~= player and to_select:canUse(Fk:cloneCard("duel"))
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local target = effect.tos[1]
    local targets = table.filter(room:getOtherPlayers(target, false), function (p)
      return p ~= player and target:canUseTo(Fk:cloneCard("duel"), p)
    end)
    if #targets > 0 then
      targets = room:askToChoosePlayers(player, {
        min_num = 1,
        max_num = 1,
        targets = targets,
        skill_name = fulong.name,
        prompt = "#lingling__fulong-choose::"..target.id,
        cancelable = false,
      })
    end
    table.insert(targets, player)
    room:askToUseVirtualCard(target, {
      name = "duel",
      skill_name = fulong.name,
      prompt = "#lingling__fulong-use",
      cancelable = false,
      extra_data = {
        exclusive_targets = table.map(targets, Util.IdMapper)
      },
    })
  end,
})

fulong:addEffect(fk.PreCardEffect, {
  can_refresh = function(self, event, target, player, data)
    return data.from == player and data.card.trueName == "duel" and table.contains(data.card.skillNames, fulong.name)
  end,
  on_refresh = function(self, event, target, player, data)
    local card = data.card:clone()
    local c = table.simpleClone(data.card)
    for k, v in pairs(c) do
      card[k] = v
    end
    card.skill = Fk.skills["lingling__fulong__duel_skill"]
    data.card = card
  end,
})

return fulong
